package com.home.admin.base;

import com.home.common.annotation.CheckApiClient;
import com.home.common.constants.client.ClientConstant;
import com.home.common.framework.core.controller.BaseController;
import com.home.webapp.base.entity.BaseDictType;
import com.home.webapp.base.service.BaseDictTypeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * Description: 字典类型表 controller
 * Created by 王大宸 on 2020-10-05 23:28:38
 * Created with IntelliJ IDEA.
 */
@Controller
@RequestMapping(value = "/base/dict/type")
@CheckApiClient(title = "数据字典类型", clientId = ClientConstant.CLIENT_WEB)
public class BaseDictTypeController extends BaseController<BaseDictTypeService, BaseDictType, String> {
    private static final Logger logger = LoggerFactory.getLogger(BaseDictTypeController.class);
    private static final String PATH_PREFIX = "base/dict/type";

    /***
     * 功能描述：跳转到信息管理界面
     *
     * @author 王大宸
     * @date 2020-10-05 23:28:38
     * @param
     * @return java.lang.String
     */
    @GetMapping(value = "/index")
    @RequiresPermissions("base:baseDictType:index")
    public String index() {
        return PATH_PREFIX + "/index";
    }

    /***
     * 功能描述：跳转到添加页面
     *
     * @author 王大宸
     * @date 2020-10-05 23:28:38
     * @param
     * @return java.lang.String
     */
    @GetMapping(value = "/add")
    @RequiresPermissions("base:baseDictType:add")
    public String add() {
        return PATH_PREFIX + "/add";
    }

    /***
     * 功能描述：跳转到修改页面
     *
     * @author 王大宸
     * @date 2020-10-05 23:28:38
     * @param id          需要修改数据的id
     * @param modelMap   modelMap
     * @return java.lang.String
     */
    @GetMapping(value = "/edit/{id}")
    @RequiresPermissions("base:baseDictType:edit")
    public String edit(@PathVariable("id") String id, ModelMap modelMap) throws Exception {
        modelMap.put("baseDictType", baseService.getById(id));
        return PATH_PREFIX + "/edit";
    }

    /***
     * 功能描述：跳转到查看页面
     *
     * @author 王大宸
     * @date 2020-10-05 23:28:38
     * @param id          需要查看数据的id
     * @param modelMap    modelMap
     * @return java.lang.String
     */
    @GetMapping(value = "/see/{id}")
    @RequiresPermissions("base:baseDictType:see")
    public String see(@PathVariable("id") String id, ModelMap modelMap) throws Exception {
        modelMap.put("baseDictType", baseService.getById(id));
        return PATH_PREFIX + "/see";
    }

}